//**************************************//
//                                      //
//                                      //
//**************************************//
#ifndef __mElements__
#define __mElements__

#include <vector>
#include <stdlib.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include "mPointArray.h"
#include "mImage.h"
#include "mMath.h"

#define e_Line 1
#define e_Arc 3
#define e_Circle 4
#define e_Triangle 5
#define e_Ray 6

class Image;

//*********//
class eLine;
class eArc;
class eCircle;
class eTriangle;
class eRay;

//*********************************//
//**                             **//
//**    BASE element 13.12.2012  **//
//**                             **//
//*********************************//
class element :public mPointArray
{
public:
    virtual mPoint p1();
    virtual mPoint p2();
    virtual mPoint p3();
    virtual mPoint cp();

    int flag;
    double r,a1,a2;
    bool direction=true;

    virtual void cArea();
    virtual bool Intersection(mPointArray *A,element);
    virtual bool Intersection(mPointArray *A,eLine);
    virtual bool Intersection(mPointArray *A,eArc);
    virtual bool Intersection(mPointArray *A,eCircle);
    virtual bool Intersection(mPointArray *A,eRay);

    //***********************//
    virtual mPoint MidPoint();

    //************************//
    virtual bool Match(element);
    virtual bool Match(eLine);
    virtual bool Match(eArc);
    virtual bool Match(eCircle);

    //************************//
    virtual bool Split(Image*,mPoint point);
    //info
    virtual bool Connection(mPoint *point,mPoint *center,int *type);
    virtual double Distance(double x,double y);

    //GetData
    virtual mPointArray ToArray(double accu=0.01);

    virtual uint T(){return 100;};
    virtual uint F(){return flag;};
    virtual wxString Info(){return _("can't be this element");};
};
//*********************************************************************//
//**
//**                eLine element 13.12.2012
//**
//*********************************************************************//
class eLine :public element
{
public:
    virtual mPoint p1();
    virtual mPoint p2();

    void cArea();
    bool Intersection(mPointArray *A,eLine);
    bool Intersection(mPointArray *A,eArc);
    bool Intersection(mPointArray *A,eCircle);
    bool Intersection(mPointArray *A,eRay);

     //***********************//
    mPoint MidPoint();

    //************************//
    bool Match(element);
    bool Match(eLine);

    //*****************************//
    bool Split(Image*,mPoint point);
    //info
    bool Connection(mPoint *point,mPoint *center,int *type);
    double Distance(double x,double y);

    //GetData
    mPointArray ToArray(double accu=0.01);
    uint T(){return e_Line;};
    wxString Info();
};
//*********************************************************************//
//**
//**                eArc element 13.12.2012
//**
//*********************************************************************//
class eArc :public element
{
public:
    virtual mPoint p1();
    virtual mPoint p2();
    virtual mPoint cp();

    void cArea();
    bool Intersection(mPointArray *A,eLine);
    bool Intersection(mPointArray *A,eArc);
    bool Intersection(mPointArray *A,eCircle);
    bool Intersection(mPointArray *A,eRay);

    //***************//
    mPoint MidPoint();

    //*************//
    bool Match(eArc);

    //******************//
    bool Split(Image*,mPoint point);
    //info
    bool Connection(mPoint *point,mPoint *center,int *type);
    double Distance(double x,double y);

    //GetData
    mPointArray ToArray(double accu=0.01);
    uint T(){return e_Arc;};
     wxString Info();
};
//*********************************************************************//
//**
//**                eCircle element 13.12.2012
//**
//*********************************************************************//
class eCircle :public element
{
public:
    virtual mPoint p1();
    virtual mPoint p2();
    virtual mPoint cp();


    void cArea();
    bool Intersection(mPointArray *A,eLine);
    bool Intersection(mPointArray *A,eArc);
    bool Intersection(mPointArray *A,eCircle);
    bool Intersection(mPointArray *A,eRay);

    //****************//
    bool Match(eCircle);

    //info
    bool Connection(mPoint *point,mPoint *center,int *type);
    virtual double Distance(double x,double y);

    //GetData
    mPointArray ToArray(double accu=0.01);
    uint T(){return e_Circle;};
    wxString Info();
};
//*********************************************************************//
//**
//**                eCircle element 13.12.2012
//**
//*********************************************************************//
class eTriangle :public element
{
public:
    virtual mPoint p1();
    virtual mPoint p2();
    virtual mPoint p3();

    void cArea();
    //bool Intersection(mPointArray *A,eLine);
    //bool Intersection(mPointArray *A,eArc);
    //bool Intersection(mPointArray *A,eCircle);
    //bool Intersection(mPointArray *A,eRay);
    //info
    //virtual double Distance(double x,double y);

    //GetData
    uint T(){return e_Triangle;};
};


//*********************************************************************//
//**
//**                eCircle element 13.12.2012
//**
//*********************************************************************//
class eRay :public element
{
public:
    virtual mPoint p1();
    virtual mPoint p2();

    void cArea();
    bool Intersection(mPointArray *A,eLine);
    bool Intersection(mPointArray *A,eArc);
    bool Intersection(mPointArray *A,eCircle);
    bool Intersection(mPointArray *A,eRay);
    //info
    //virtual double Distance(double x,double y);

    //GetData
    uint T(){return e_Ray;};
};

  eLine eL(mPoint p1 , mPoint p2,wxString L=_("0"));
   eArc eA(mPoint cp , double a1 , double a2 , double R,wxString L=_("0"));
   eArc eA(mPoint p1 , mPoint p2, double R,wxString L=_("0"));
eCircle eC(mPoint cp , double r,wxString L=_("0"));
eTriangle eT(mPoint p1,mPoint p2,mPoint p3 , wxString L=_("0"));
   eRay eR(mPoint p1 , mPoint p2,wxString L=_("0"));

#endif
